package dnaSequencer;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;

public class ResultsParser {
	private static BufferedReader in = null;
	private static int l;
	private static int n;

	public static ArrayList<String> loadResultsFromFile(String fileName)
			throws FileNotFoundException {
		in = new BufferedReader(new FileReader(fileName));

		String tmp = null;
		ArrayList<String> tablica = new ArrayList<String>();
		try {
			while ((tmp = in.readLine()) != null) {
				tablica.add(tmp);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		try {
			in.close();
		} catch (IOException e) {
			e.printStackTrace();
		}

		l = tablica.get(0).length();

		if (fileName.indexOf('-') > 0)
			n = Integer.parseInt(fileName.substring(fileName.lastIndexOf('.') + 1,
					fileName.indexOf('-')));
		else
			n = Integer.parseInt(fileName.substring(fileName.lastIndexOf('.') + 1,
					fileName.indexOf('+')));

		return tablica;
	}

	public static int getL() {
		return l;
	}

	public static int getN() {
		return n + l - 1;
	}

}
